/*
 * PKL 51 GUNUNG KIDUL
 * Subseksie DATA ENTRY + CAPI
 */
package pkl51.validasi;

import pkl51.component.TextField;
import pkl51.controller.CardKues;
import pkl51.view.kuesioner.PanelBlok6A;

/**
 *
 * @author FITRI ANDRI ASTUTI
 */
public class ValidasiBlok6A extends AbstractValidasi{
    private PanelBlok6A panelBlok6A;

    public void setPanelBlok6A(PanelBlok6A panelBlok6A) {
        this.panelBlok6A = panelBlok6A;
    }

    public ValidasiBlok6A() {
    }
    
    public void registerValidator() {
        panelBlok6A.getTextFieldB6AR1a().setValidator(new ValidasiB6AR1a());
        panelBlok6A.getTextFieldB6AR1b().setValidator(new ValidasiB6AR1b());
        panelBlok6A.getTextFieldB6AR2a().setValidator(new ValidasiB6AR2a());
        panelBlok6A.getTextFieldB6AR2b().setValidator(new ValidasiB6AR2b());
        panelBlok6A.getTextFieldB6AR2c().setValidator(new ValidasiB6AR2c());
        panelBlok6A.getTextFieldB6AR2d().setValidator(new ValidasiB6AR2d());
        panelBlok6A.getTextFieldB6AR2e().setValidator(new ValidasiB6AR2e());
        panelBlok6A.getTextFieldB6AR2f().setValidator(new ValidasiB6AR2f());
        panelBlok6A.getTextFieldB6AR2g().setValidator(new ValidasiB6AR2g());
        panelBlok6A.getTextFieldB6AR2h().setValidator(new ValidasiB6AR2h());
        panelBlok6A.getTextFieldB6AR2i().setValidator(new ValidasiB6AR2i());
        panelBlok6A.getTextFieldB6AR2j().setValidator(new ValidasiB6AR2j());
        panelBlok6A.getTextFieldB6AR2k().setValidator(new ValidasiB6AR2k());
        panelBlok6A.getTextFieldB6AR2l().setValidator(new ValidasiB6AR2l());
        panelBlok6A.getTextFieldB6AR2m().setValidator(new ValidasiB6AR2m());
        panelBlok6A.getTextFieldB6AR2n().setValidator(new ValidasiB6AR2n());
        panelBlok6A.getTextFieldB6AR2o().setValidator(new ValidasiB6AR2o());
    }
    
    private class ValidasiB6AR1a implements Validator {
        @Override
        public boolean onCheckValue(TextField field) {
            if(Integer.parseInt(field.getText())>= 1 && Integer.parseInt(field.getText()) <= 99 && Integer.parseInt(field.getText()) != 5) {
                field.setNextFocusableComponent(panelBlok6A.getTextFieldB6AR1b());
                return true;
            }
            else{
                errorMessage("Nilai antara 1 sampai 99 dan tidak boleh 5");
                return false;
            }
        }
    }
    
    private class ValidasiB6AR1b implements Validator {
        @Override
        public boolean onCheckValue(TextField field) {
            if(Integer.parseInt(field.getText())>= 1 && Integer.parseInt(field.getText()) <= 99 && Integer.parseInt(field.getText()) != 5) {
                field.setNextFocusableComponent(panelBlok6A.getTextFieldB6AR2a());
                return true;
            }
            else{
                errorMessage("Nilai antara 1 sampai 99 dan tidak boleh 5");
                return false;
            }
        }
    }
    private class ValidasiB6AR2a implements Validator {
        @Override
        public boolean onCheckValue(TextField field) {
            if(Integer.parseInt(field.getText())>= 1 && Integer.parseInt(field.getText()) <= 4) {
                field.setNextFocusableComponent(panelBlok6A.getTextFieldB6AR2b());
                return true;
            }
            else{
                errorMessage("Nilai antara 1 sampai 4");
                return false;
            }
        }
    }
    private class ValidasiB6AR2b implements Validator {
        @Override
        public boolean onCheckValue(TextField field) {
            if(Integer.parseInt(field.getText())>= 1 && Integer.parseInt(field.getText()) <= 4) {
                field.setNextFocusableComponent(panelBlok6A.getTextFieldB6AR2c());
                return true;
            }
            else{
                errorMessage("Nilai antara 1 sampai 4");
                return false;
            }
        }
    }
    private class ValidasiB6AR2c implements Validator {
        @Override
        public boolean onCheckValue(TextField field) {
            if(Integer.parseInt(field.getText())>= 1 && Integer.parseInt(field.getText()) <= 4) {
                field.setNextFocusableComponent(panelBlok6A.getTextFieldB6AR2d());
                return true;
            }
            else{
                errorMessage("Nilai antara 1 sampai 4");
                return false;
            }
        }
    }
    private class ValidasiB6AR2d implements Validator {
        @Override
        public boolean onCheckValue(TextField field) {
            if(Integer.parseInt(field.getText())>= 1 && Integer.parseInt(field.getText()) <= 4) {
                field.setNextFocusableComponent(panelBlok6A.getTextFieldB6AR2e());
                return true;
            }
            else{
                errorMessage("Nilai antara 1 sampai 4");
                return false;
            }
        }
    }
    private class ValidasiB6AR2e implements Validator {
        @Override
        public boolean onCheckValue(TextField field) {
            if(Integer.parseInt(field.getText())>= 1 && Integer.parseInt(field.getText()) <= 4) {
                field.setNextFocusableComponent(panelBlok6A.getTextFieldB6AR2f());
                return true;
            }
            else{
                errorMessage("Nilai antara 1 sampai 4");
                return false;
            }
        }
    }
    private class ValidasiB6AR2f implements Validator {
        @Override
        public boolean onCheckValue(TextField field) {
            if(Integer.parseInt(field.getText())>= 1 && Integer.parseInt(field.getText()) <= 4) {
                field.setNextFocusableComponent(panelBlok6A.getTextFieldB6AR2g());
                return true;
            }
            else{
                errorMessage("Nilai antara 1 sampai 4");
                return false;
            }
        }
    }
    private class ValidasiB6AR2g implements Validator {
        @Override
        public boolean onCheckValue(TextField field) {
            if(Integer.parseInt(field.getText())>= 1 && Integer.parseInt(field.getText()) <= 4) {
                field.setNextFocusableComponent(panelBlok6A.getTextFieldB6AR2h());
                return true;
            }
            else{
                errorMessage("Nilai antara 1 sampai 4");
                return false;
            }
        }
    }
    private class ValidasiB6AR2h implements Validator {
        @Override
        public boolean onCheckValue(TextField field) {
            if(Integer.parseInt(field.getText())>= 1 && Integer.parseInt(field.getText()) <= 4) {
                field.setNextFocusableComponent(panelBlok6A.getTextFieldB6AR2i());
                return true;
            }
            else{
                errorMessage("Nilai antara 1 sampai 4");
                return false;
            }
        }
    }
    private class ValidasiB6AR2i implements Validator {
        @Override
        public boolean onCheckValue(TextField field) {
            if(Integer.parseInt(field.getText())>= 1 && Integer.parseInt(field.getText()) <= 4) {
                field.setNextFocusableComponent(panelBlok6A.getTextFieldB6AR2j());
                return true;
            }
            else{
                errorMessage("Nilai antara 1 sampai 4");
                return false;
            }
        }
    }
    private class ValidasiB6AR2j implements Validator {
        @Override
        public boolean onCheckValue(TextField field) {
            if(Integer.parseInt(field.getText())>= 1 && Integer.parseInt(field.getText()) <= 4) {
                field.setNextFocusableComponent(panelBlok6A.getTextFieldB6AR2k());
                return true;
            }
            else{
                errorMessage("Nilai antara 1 sampai 4");
                return false;
            }
        }
    }
    private class ValidasiB6AR2k implements Validator {
        @Override
        public boolean onCheckValue(TextField field) {
            if(Integer.parseInt(field.getText())>= 1 && Integer.parseInt(field.getText()) <= 4) {
                field.setNextFocusableComponent(panelBlok6A.getTextFieldB6AR2l());
                return true;
            }
            else{
                errorMessage("Nilai antara 1 sampai 4");
                return false;
            }
        }
    }
    private class ValidasiB6AR2l implements Validator {
        @Override
        public boolean onCheckValue(TextField field) {
            if(Integer.parseInt(field.getText())>= 1 && Integer.parseInt(field.getText()) <= 4) {
                field.setNextFocusableComponent(panelBlok6A.getTextFieldB6AR2m());
                return true;
            }
            else{
                errorMessage("Nilai antara 1 sampai 4");
                return false;
            }
        }
    }
    private class ValidasiB6AR2m implements Validator {
        @Override
        public boolean onCheckValue(TextField field) {
            if(Integer.parseInt(field.getText())>= 1 && Integer.parseInt(field.getText()) <= 4) {
                field.setNextFocusableComponent(panelBlok6A.getTextFieldB6AR2n());
                return true;
            }
            else{
                errorMessage("Nilai antara 1 sampai 4");
                return false;
            }
        }
    }
    private class ValidasiB6AR2n implements Validator {
        @Override
        public boolean onCheckValue(TextField field) {
            if(Integer.parseInt(field.getText())>= 1 && Integer.parseInt(field.getText()) <= 4) {
                field.setNextFocusableComponent(panelBlok6A.getTextFieldB6AR2o());
                return true;
            }
            else{
                errorMessage("Nilai antara 1 sampai 4");
                return false;
            }
        }
    }
    private class ValidasiB6AR2o implements Validator {
        @Override
        public boolean onCheckValue(TextField field) {
            if(Integer.parseInt(field.getText())>= 1 && Integer.parseInt(field.getText()) <= 4) {
                CardKues.getCard().next();
                return true;
            }
            else{
                errorMessage("Nilai antara 1 sampai 4");
                return false;
            }
        }
    }
}